// pages/Draft/userview/userview.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jiaimg: "../../../images/home/add.jpg",
    yiimg: "../../../images/home/add.jpg",
    click: false, //是否显示弹窗内容
    option: false, //显示弹窗或关闭弹窗的操作动画
    jiafang: "",
    phone:"",
    yiloushow:false,
    htpic:''
  },
  choosejiaWxImage: function (type) {
    var that = this;
    wx.chooseImage({
      sizeType: ['original', 'compressed'],
      sourceType: [type],
      success: function (res) {
        console.log(res);
        that.setData({
          // tempFilePath可以作为img标签的src属性显示图片
          jiaimg: res.tempFilePaths[0],
        })
      }
    })
  },
  chiosejiaimage: function () {
    var that = this;
    wx.showActionSheet({
      itemList: ['从相册中选择', '拍照'],
      itemColor: "#aaaaaa",
      success: function (res) {
        if (!res.cancel) {
          if (res.tapIndex == 0) {
            that.choosejiaWxImage('album')
          } else if (res.tapIndex == 1) {
            that.choosejiaWxImage('camera')
          }
        }
      }
    })
  },

  // 乙的拍照
  chooseyiWxImage: function (type) {
    var that = this;
    wx.chooseImage({
      sizeType: ['original', 'compressed'],
      sourceType: [type],
      success: function (res) {
        console.log(res);
        that.setData({
          // tempFilePath可以作为img标签的src属性显示图片
          yiimg: res.tempFilePaths[0],
        })
      }
    })
  },
  //乙的拍照
  chioseyiimage: function () {
    var that = this;
    wx.showActionSheet({
      itemList: ['从相册中选择', '拍照'],
      itemColor: "#aaaaaa",
      success: function (res) {
        if (!res.cancel) {
          if (res.tapIndex == 0) {
            that.chooseyiWxImage('album')
          } else if (res.tapIndex == 1) {
            that.chooseyiWxImage('camera')
          }
        }
      }
    })
  },
  yilouclick:function(e){
    this.setData({
      yiloushow: true,
    })
  },
  enterPdfcont:function(e){
    wx: wx.navigateTo({
      url: '../fullcontent/editview',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  sendemail:function(){
    this.setData({
      click: false, //是否显示弹窗内容
      option: false, //显示弹窗或关闭弹窗的操作动画
      
    })
    
    wx.navigateTo({
      url: '../../sendemail/sendemail',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  prompt:function(e){
    this.setData({
     jiafang:"例：老王",
     phone:"例:18099995555",
    })
  },
  // 用户点击显示弹窗
  clickPup: function () {
    let _that = this;
    if (!_that.data.click) {
      _that.setData({
        click: true,
      })
    }

    if (_that.data.option) {
      _that.setData({
        option: false,
      })

      // 关闭显示弹窗动画的内容，不设置的话会出现：点击任何地方都会出现弹窗，就不是指定位置点击出现弹窗了
      setTimeout(() => {
        _that.setData({
          click: false,
        })
      }, 500)


    } else {
      _that.setData({
        option: true
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    this.setData({

      detail: options.detail,
      htpic: wx.getStorageSync("htPic")

    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    wx.reLaunch({
      url: '../Draft'
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  dofast:function(){
    wx:wx.navigateTo({
      url: '../editview/editview?detail='+this.data.detail,
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  }
})